import {defineStore} from "pinia";
import {Adminroot, user} from "@/api";
import router from "@/router";
export const storeVuex = defineStore("userStore", {
    state: () => ({
        userInfo:{},
        username:'',
        accessToken:'',
        userType_id: '',//店铺凭证
        isDarkMode:false,//深色模式
        //用户资料
        hotelList:[],//饭店列表
        shopList:[],//产品列表
        shopClsssList:[],//产品分类列表
        MenuList:[],    //导航栏
        RootRoute:[],    //可访问权限路由列表
        isEcharts:false, //作为echarts监听隐藏导航栏的开关使用
        GpsShopList:{
            shop:[
                {
                    name: "俩义轩黄牛肉批零商行",
                    coordinates: { longitude: 114.3167672950514, latitude: 30.357910981681197 }
                },
                {
                    name: "清伊赛牛肉",
                    coordinates: { longitude: 114.3014360218694, latitude: 30.347737069704486 }
                },
                {
                    name: "虎记清真牛羊肉",
                    coordinates: { longitude: 114.31671998728436, latitude: 30.348795875438498 }
                }
                ],
            dflz:[
                {
                    name: "快递驿站",
                    coordinates: { longitude: 121.03195756897861, latitude: 30.681951003661332 }
                },
                {
                    name: "超市",
                    coordinates: { longitude: 121.03240347115837, latitude: 30.68168790686768 }
                },
                {
                    name: "家",
                    coordinates: { longitude: 121.03227008791106, latitude: 30.68291613929838 }
                }
                ],
            customer:[
                {
                    name: "谢氏老金口-生炸鱼丸",
                    coordinates: { longitude: 114.31776101166433, latitude: 30.357328262419323 }
                },
                {
                    name: "谢氏老金口-鲜鱼楼",
                    coordinates: { longitude: 114.31957157399532, latitude: 30.35728418527527 }
                },
                {
                    name: "谢氏老金口-泽霖居",
                    coordinates: { longitude: 114.36408769433227, latitude: 30.381229380206882 },
                    line:[
                        [114.31685762885856,30.357774924530627],
                        [114.3165468368824,30.357013041591905],
                        [114.31431455704664,30.35679097916735],
                        [114.31197810216213,30.370332583764423],


                        [114.3329260342836,30.370354158026284],
                        [114.33382864082581,30.37018306361339],
                        [114.3357979126859,30.37069280674231],
                        [114.34664458796348,30.37234266262515],
                        [114.34874853233707,30.372656151454994],
                        [114.34980176884137,30.372875139986505],
                        [114.35113075765511,30.373290782424874],
                        [114.35229089191103,30.37381117415371],
                        [114.35377574657973,30.375038879203984],
                        [114.35556613572203,30.375482433035035],
                        [114.36066150890737,30.377898434041114],
                        [114.36228129089487,30.37840476966906],
                        [114.36433206287042,30.37871215415335],
                        [114.3664101183443,30.378645246561025],
                        [114.36651446886867,30.38222159277543],
                        [114.36608985542863,30.382197455569838],
                        [114.36547033919791,30.381153390821225],
                        [114.36448190285908,30.381449104594314],
                        [114.36402249198842,30.380936115182813]
                    ]
                },
                {
                    name: "谢氏老金口-七号宴",
                    coordinates: { longitude: 114.30730356293367, latitude: 30.372162386409393 },
                    line: [
                            [114.31685762885856,30.357774924530627],
                            [114.3165468368824,30.357013041591905],
                            [114.31431455704664,30.35679097916735],
                            [114.31200341535501,30.370580318510413],
                            [114.30785742925595,30.370628282012078],
                            [114.30776261789863,30.371728520643284],
                            [114.3073602516999,30.371708501684942],
                            [114.30731406659879,30.37206457325667]
                        ]
                },
                {
                    name: "谢氏老金口-九號别苑",
                    coordinates: { longitude: 114.08285363152353, latitude: 30.353668768921988 }
                },
                {
                    name: "梁记粥铺",
                    coordinates: { longitude: 114.32462635439343, latitude: 30.36333844907726 }
                },],
            line:[
                [
                    [114.31676439769812, 30.3579281187644],
                    [114.31691625645904, 30.357887621709384],
                ],
                [
                    [114.31691625645904, 30.357887621709384],
                    [114.31659370096743, 30.35701950287502]
                ],
                [
                    [114.31691625645904, 30.357887621709384],
                    [114.31659370096743, 30.35701950287502]
                ],
                [
                    [114.31659370096743, 30.35701950287502],
                    [114.3143159864099, 30.35677922430576]
                ],
                [
                    [114.3143159864099, 30.35677922430576],
                    [114.3119069673527, 30.3705193393504]
                ],
                [
                    [114.3119069673527, 30.3705193393504],
                    [114.30789579239868,30.37056849557945]
                ],
                [
                    [114.30789579239868,30.37056849557945],
                    [114.3077310866784, 30.372155458208752]
                ],
                [
                    [114.3077310866784, 30.372155458208752],
                    [114.30730417795989,30.372165306972015]
                ],
                [
                    [114.31659404895119,30.3570214067924],
                    [114.31784133862013,30.35710980077754]
                ],
                [
                    [114.31784133862013,30.35710980077754],
                    [114.31774984576411,30.357356700094204]
                ],
                [
                    [114.31784133862013,30.35710980077754],
                    [114.31840826081915,30.357179262213158]
                ],
                [
                    [114.31840826081915,30.357179262213158],
                    [114.31838367616164,30.357409182103158]
                ],
                [
                    [114.31838367616164,30.357409182103158],
                    [114.31876792917258,30.357440933674535]
                ],
                [
                    [114.31876792917258,30.357440933674535],
                    [114.31881659358403,30.357265389675295]
                ],
                [
                    [114.31881659358403,30.357265389675295],
                    [114.31950448901532,30.357449961403614]
                ],
                [
                    [114.31950448901532,30.357449961403614],
                    [114.31956814732281,30.35729146754301]
                ],
                [
                    [114.31950448901532,30.357449961403614],
                    [114.3205831073493,30.357789187777904]
                ],
                [
                    [114.3205831073493,30.357789187777904],
                    [114.32088224338231,30.360541310934572]
                ],
                [
                    [114.32088224338231,30.360541310934572],
                    [114.33923356105758,30.359914479205038]
                ],
                [
                    [114.33923356105758,30.359914479205038],
                    [114.34541891433986,30.359076102534345]
                ],
                [
                    [114.34541891433986,30.359076102534345],
                    [114.34615508857752,30.361461314023302]
                ],
                [
                    [114.34615508857752,30.361461314023302],
                    [114.34721730281294,30.362933829033793]
                ],
                [
                    [114.34721730281294,30.362933829033793],
                    [114.3471012151813,30.37245165552534]
                ],
                [
                    [114.3471012151813,30.37245165552534],
                    [114.3506021846341,30.373109219862457]
                ],
                [
                    [114.3506021846341,30.373109219862457],
                    [114.35370243481206,30.3750186664697]
                ],
                [
                    [114.35370243481206,30.3750186664697],
                    [114.35562279064472,30.375499330861476]
                ],
                [
                    [114.35562279064472,30.375499330861476],
                    [114.36214926687153,30.378350113272766]
                ],
                [
                    [114.36214926687153,30.378350113272766],
                    [114.36641049088651,30.378702592328345]
                ],
                [
                    [114.36641049088651,30.378702592328345],
                    [114.36651369014037,30.38216179452351]
                ],
                [
                    [114.36651369014037,30.38216179452351],
                    [114.36610338335835,30.38216179457427]
                ],
                [
                    [114.36610338335835,30.38216179457427],
                    [114.36547816107732,30.381139760743242]
                ],
                [
                    [114.36547816107732,30.381139760743242],
                    [114.36443611799623,30.381455962958935]
                ],
                [
                    [114.36443611799623,30.381455962958935],
                    [114.36409482148942,30.381239638902237]
                ],
                [
                    [114.3248515536112,30.360400652250025],
                    [114.3270341665125,30.362772926994406]
                ],

                [
                    [114.3270341665125,30.362772926994406],
                    [114.32462315870713,30.363754246250068]
                ],
                [
                    [114.32462315870713,30.363754246250068],
                    [114.32461494742,30.36336721237644]
                ],
                [
                    [114.30772168407462,30.372151765708846],
                    [114.30608408009338,30.37914203447592]
                ],
                [
                    [114.30608408009338,30.37914203447592],
                    [114.30096910462011,30.37832851763692]
                ],
                [
                    [114.30096910462011,30.37832851763692],
                    [114.26557392307153,30.379379391620876]
                ],
                [
                    [114.26557392307153,30.379379391620876],
                    [114.26105807743303,30.378410238592462]
                ],
                [
                    [114.26105807743303,30.378410238592462],
                    [114.24630529898563,30.380526023963405]
                ],
                [
                    [114.24630529898563,30.380526023963405],
                    [114.22980734688333,30.38206602100946]
                ],
                [
                    [114.22980734688333,30.38206602100946],
                    [114.22612629875395,30.381558581946265]
                ],
                [
                    [114.22612629875395,30.381558581946265],
                    [114.22329450693404,30.38024177361969]
                ],
                [
                    [114.22329450693404,30.38024177361969],
                    [114.21998585268236,30.377523317275497]
                ],[
                    [114.21998585268236,30.377523317275497],
                    [114.21708217019653,30.375941019254366]
                ],
                [
                    [114.21708217019653,30.375941019254366],
                    [114.21468771084946,30.374934843909607]
                ],
                [
                    [114.21468771084946,30.374934843909607],
                    [114.20048882964026,30.373225598721962]
                ],
                [
                    [114.20048882964026,30.373225598721962],
                    [114.17976078008023,30.371099696096245]
                ],
                [
                    [114.17976078008023,30.371099696096245],
                    [114.17672679698998,30.368205539937655]
                ],
                [
                    [114.17672679698998,30.368205539937655],
                    [114.1751618945,30.36493143958753]
                ],[
                    [114.1751618945,30.36493143958753],
                    [114.17309149141276,30.3537447563963]
                ],
                [
                    [114.17309149141276,30.3537447563963],
                    [114.17288917642982,30.35339588609271]
                ],
                [
                    [114.17288917642982,30.35339588609271],
                    [114.17070963070927,30.349519412594354]
                ],
                [
                    [114.17070963070927,30.349519412594354],
                    [114.16599229233793,30.35349045902877]
                ],
                [
                    [114.16599229233793,30.35349045902877],
                    [114.16042156804781,30.35913497413315]
                ],[
                    [114.16042156804781,30.35913497413315],
                    [114.15402263283791,30.364356262152516]
                ],
                [
                    [114.15402263283791,30.364356262152516],
                    [114.12837316029295,30.38261434025785]
                ],
                [
                    [114.12837316029295,30.38261434025785],
                    [114.11393419977492,30.3903683580084]
                ],
                [
                    [114.11393419977492,30.3903683580084],
                    [114.10693709630438,30.38163107087925]
                ],
                [
                    [114.10693709630438,30.38163107087925],
                    [114.10682488333262,30.381332634508997]
                ],
                [
                    [114.10682488333262,30.381332634508997],
                    [114.10517967670908,30.374718337225993]
                ],
                [
                    [114.10517967670908,30.374718337225993],
                    [114.09880697347756,30.365240930677444]
                ],
                [
                    [114.09880697347756,30.365240930677444],
                    [114.09932610241451,30.36277355104567]
                ],
                [
                    [114.09932610241451,30.36277355104567],
                    [114.09588669771435,30.35818931720304]
                ],
                [
                    [114.09588669771435,30.35818931720304],
                    [114.08916384679887,30.354507670460233]
                ],
                [
                    [114.08916384679887,30.354507670460233],
                    [114.08484293349441,30.350316479677513]
                ],
                [
                    [114.08484293349441,30.350316479677513],
                    [114.08395988218273,30.3510323231186]
                ],
                [
                    [114.08395988218273,30.3510323231186],
                    [114.08302215861443,30.353864375764108]
                ],
                [
                    [114.08302215861443,30.353864375764108],
                    [114.0827227729746,30.353844144441194]
                ],
                [
                    [114.0827227729746,30.353844144441194],
                    [114.0828511323857,30.35367793075079]
                ]
            ],
            addShopGps:[
                114.20596490541152,30.598171934433218,
                114.20651469471791,30.598066838262582,
                114.20627736900973,30.59712446308316,
                114.20576114030816,30.597215937282403
            ],
            homeShopGps:[
                113.34072780337813,33.598033818371626,
                113.34235409557265,33.59780875275479,
                113.34204298401048,33.596296721372475,
                113.340112171058,33.59669244293198,
                113.34072780337813,33.598033818371626
            ]
        }
    }),
    actions: {
        async login(username: string, password: string) {
            const { data } = await user.Login(username, password);
            this.accessToken = data.data.token;
        },
        // 获取用户权限导航菜单
        async getUserRootMenu(username: string,) {
            const  data  = await user.getAdminRoute_List({username});
            this.MenuList = data.data.data
        },
        // 获取用户权限组
        async getUserRoot(id: string,) {
            const  data  = await Adminroot.getUserRoot({id});
            this.RootRoute = data.data.data[0];
        },
        // 退出登陆
        async logout() {
             this.accessToken = "";
             this.userInfo = {};
             this.RootRoute = [];
            //已经是登录页就不跳转了
            if(router.currentRoute.value.fullPath!='/login'){
                await router.push('/login');
            }
        },
    },
    persist: true
});
// 删除token
const removeToken=()=>{
}
// 删除路由
const resetRouter=()=>{

}
